//
//  WCGradientTableHeaderCell.m
//  WabbitCode
//
//  Created by William Towe on 1/22/09.
//  Copyright 2009 Revolution Software. All rights reserved.
//

#import "WCGradientTableHeaderCell.h"


@implementation WCGradientTableHeaderCell
- (id)initTextCell:(NSString *)string {
	if (!(self = [super initTextCell:string]))
		return nil;
	
	[self setBackgroundStyle:NSBackgroundStyleRaised];
	[self setAlignment:NSCenterTextAlignment];
	
	return self;
}

- (void)drawWithFrame:(NSRect)inFrame inView:(NSView *)inView {
	static NSColor *bottomLineColor = nil;
	static NSGradient *fillGradient = nil;
	if (!bottomLineColor) {
		bottomLineColor = [[NSColor colorWithCalibratedWhite:101.0/255.0 alpha:1.0] retain];
		fillGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:232.0/255.0 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:138.0/255.0 alpha:1.0]];
	}
	
	[bottomLineColor setFill];
	NSRectFill(NSMakeRect(inFrame.origin.x, inFrame.origin.y+inFrame.size.height-1.0, inFrame.size.width, 1.0));
	
	[fillGradient drawInRect:NSMakeRect(inFrame.origin.x, inFrame.origin.y, inFrame.size.width, inFrame.size.height-1.0) angle:90.0];
	
	[super drawInteriorWithFrame:NSOffsetRect(inFrame, 0, 1) inView:inView];
}
@end
